﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class GameManager : MonoBehaviour
{
    public static GameManager instance;
    public Text end_text;
    public GameObject end_menu;
    private BuildManager build_manager;
    private void Awake()
    {
        instance = this;
        build_manager = GetComponent<BuildManager>();
    }

    public void Win()
    {
        StopCoroutine(EnemySpawner.spawner);
        end_text.text = "胜 利";
        build_manager.DenyBuild();
        end_menu.SetActive(true);
    }
    public void Lose()
    {
        StopCoroutine(EnemySpawner.spawner);
        end_text.text = "失 败";
        build_manager.DenyBuild();
        end_menu.SetActive(true);
    }

    public void Restart()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); //重新加载
    }
    public void ToMenu()
    {
        SceneManager.LoadScene(0);
    }
}
